<template>
  <!-- <div class="score">
    <div class="label-item flexbox flex-align-center">
      <div class="line"></div>
      <span class="text">{{ $t("orderPage.overallRating") }}</span>
    </div>
    <div class="box flexbox flex-align-center flex-justify-between">
      <div class="score-left">
        <div class="num">{{ scoreInfo.avg }}</div>
        <div class="get-star flexbox flex-align-center">
          <div class="star-item" v-for="item in 5" :key="item">
            <img
              loading="lazy"
              class="star-icon"
              v-if="item > scoreInfo.avg"
              src="https://cd.sealmg.com/assets/img/star-gray.png"
              alt="https://cd.sealmg.com/assets/img/star-gray.png"
              srcset=""
            />
            <img
              loading="lazy"
              class="star-icon"
              v-else
              src="https://cd.sealmg.com/assets/img/star.png"
              alt="https://cd.sealmg.com/assets/img/star.png"
              srcset=""
            />
          </div>
        </div>
      </div>
      <div class="score-right">
        <div
          class="star-rate flexbox flex-align-center"
          v-for="(item, index) in scoreInfo.scores"
          :key="index"
        >
          <div class="star-box flexbox flex-align-center flex-justify-end">
            <img
              loading="lazy"
              class="star-icon"
              v-for="num in item.score"
              :key="num"
              src="https://cd.sealmg.com/assets/img/star-mini.png"
              alt="https://cd.sealmg.com/assets/img/star-mini.png"
              srcset=""
            />
          </div>
          <div class="progress flex-1">
            <el-progress
              :percentage="item.percent"
              :stroke-width="4"
              :show-text="false"
              color="#FF4E33"
              define-back-color="#FFD4C4"
            ></el-progress>
          </div>
          <div class="rate">{{ item.percent }}%</div>
        </div>
      </div>
    </div>
  </div> -->
  <div class="bg-[#FAF9F9] rounded-[1.25rem] lg:p-5 p-3 grid grid-cols-3 lg:gap-12 gap-4">
    <div class="flex flex-col col-span-1">
      <div class="font-bold lg:text-[3rem] text-[1.5rem] text-[#121212]">
        {{ scoreInfo.avg }}
      </div>
      <div class="font-semibold text-[1.25rem] text-[#121212]">Average</div>
      <div class="lg:gap-2 flex items-center">
        <div class="star-item" v-for="item in 5" :key="item">
          <img
            loading="lazy"
            class="size-4 flex-none"
            v-if="item > scoreInfo.avg"
            src="https://cd.sealmg.com/assets/img/star-gray.png"
            alt="https://cd.sealmg.com/assets/img/star-gray.png"
            srcset=""
          />
          <img
            loading="lazy"
            class="size-4 flex-none"
            v-else
            src="https://cd.sealmg.com/assets/img/star.png"
            alt="https://cd.sealmg.com/assets/img/star.png"
            srcset=""
          />
        </div>
      </div>
      <span class="font-semibold text-[0.88rem] text-[#121212]"> {{ totalScore }} {{ $t('orderPage.score') }} </span>
      <!-- <div class="font-semibold text-[0.88rem] text-[#121212]">90 reviews</div> -->
    </div>
    <div class="flex flex-col col-span-2 justify-between">
      <div class="flex gap-3 justify-between items-center" v-for="(item, index) in scoreInfo.scores" :key="index">
        <div class="flex justify-end items-center w-16">
          <img
            loading="lazy"
            class="size-3 flex-none"
            v-for="num in item.score"
            :key="num"
            src="https://cd.sealmg.com/assets/img/star-mini.png"
            alt="star-icon"
            title="star-icon"
            srcset
          />
        </div>
        <!-- <div class="font-bold text-[0.94rem] text-[#121212]">
          {{ scoreInfo.scores.length - index }}
        </div> -->
        <div class="flex-1">
          <el-progress :percentage="item.percent" :stroke-width="8" :show-text="false" color="#FF4E33" define-back-color="#E6E6E6"></el-progress>
        </div>
        <div class="w-7 text-[.75rem] text-black/50">{{ item.percent }}%</div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    props: {
      detailInfo: {
        type: Object,
        default: () => {}
      },
      totalScore: {
        type: Number,
        default: 0
      }
    },
    data() {
      return {
        scoreInfo: this.detailInfo
      }
    },
    watch: {
      detailInfo: {
        handler(newVal) {
          this.scoreInfo = newVal
        },
        deep: true,
        immated: true
      }
    },
    computed: {},
    created() {},
    methods: {}
  }
</script>
<style lang="less" scoped>
  .label-item {
    margin-top: 32px;
    margin-bottom: 32px;
    .line {
      width: 5px;
      height: 18px;
      background: @theme-color;
      border-radius: 4px;
    }
    .text {
      margin-left: 8px;
      font-weight: 500;
      font-size: 20px;
      color: @font-color-14;
    }
  }
  .score {
    .box {
      box-sizing: border-box;
      padding: 24px 32px;
      width: 745px;
      height: 133px;
      background: @color-f7;
      border-radius: 16px;
    }
    .score-left {
      .num {
        font-family: Manrope, Manrope;
        font-weight: bold;
        font-size: 32px;
        color: @font-color-26;
      }
      .get-star {
        margin-top: 10px;
        .star-item {
          width: 20px;
          height: 20px;
          margin-left: 8px;
          .star-icon {
            width: 20px;
            height: 20px;
          }
        }
        .star-item:first-child {
          margin-left: 0px;
        }
      }
    }
    .score-right {
      .star-rate {
        width: 437px;
        .star-box {
          width: 76px;
          .star-icon {
            width: 12px;
            height: 12px;
            margin-left: 4px;
          }
          .star-icon:first-child {
            margin-left: 0px;
          }
        }
      }
      .progress {
        margin-left: 8px;
      }
      .rate {
        width: 32px;
        text-align: left;
        margin-left: 16px;
        font-family: Manrope, Manrope;
        font-weight: 500;
        font-size: 12px;
        color: #b3b3b3;
      }
    }
  }
  @media only screen and (min-width: 1200px) {
  }
  @media screen and (max-width: 992px) and (min-width: 768px) {
    .label-item {
      margin-top: 0px;
      margin-bottom: 16px;
      .line {
        width: 5px;
        height: 18px;
        background: @theme-color;
        border-radius: 4px;
      }
      .text {
        margin-left: 8px;
        font-weight: 500;
        font-size: 20px;
        color: @font-color-14;
      }
    }
    .score {
      margin-top: 12px;
      .box {
        box-sizing: border-box;
        padding: 16px;
        width: 100%;
        height: auto;
        background: @color-f7;
        border-radius: 11px;
      }
      .score-left {
        .num {
          font-family: Manrope, Manrope;
          font-weight: bold;
          font-size: 24px;
          color: @font-color-26;
        }
        .get-star {
          margin-top: 16px;
          .star-item {
            width: 12px;
            height: 12px;
            margin-left: 4px;
            .star-icon {
              width: 12px;
              height: 12px;
            }
          }
          .star-item:first-child {
            margin-left: 0px;
          }
        }
      }
      .score-right {
        .star-rate {
          width: 200px;
          .star-box {
            width: 48px;
            .star-icon {
              width: 8px;
              height: 8px;
              margin-left: 2px;
            }
            .star-icon:first-child {
              margin-left: 0px;
            }
          }
        }
        .progress {
          margin-left: 6px;
        }
        .rate {
          width: 28px;
          margin-left: 6px;
          font-weight: 500;
          font-size: 10px;
          color: #b3b3b3;
        }
      }
    }
  }
  @media screen and (max-width: 767px) {
    .label-item {
      margin-top: 0px;
      margin-bottom: 16px;
      .line {
        width: 5px;
        height: 18px;
        background: @theme-color;
        border-radius: 4px;
      }
      .text {
        margin-left: 8px;
        font-weight: 500;
        font-size: 20px;
        color: @font-color-14;
      }
    }
    .score {
      margin-top: 12px;
      .box {
        box-sizing: border-box;
        padding: 16px;
        width: 100%;
        height: auto;
        background: @color-f7;
        border-radius: 11px;
      }
      .score-left {
        .num {
          font-family: Manrope, Manrope;
          font-weight: bold;
          font-size: 24px;
          color: @font-color-26;
        }
        .get-star {
          margin-top: 16px;
          .star-item {
            width: 12px;
            height: 12px;
            margin-left: 4px;
            .star-icon {
              width: 12px;
              height: 12px;
            }
          }
          .star-item:first-child {
            margin-left: 0px;
          }
        }
      }
      .score-right {
        .star-rate {
          width: 200px;
          .star-box {
            width: 48px;
            .star-icon {
              width: 8px;
              height: 8px;
              margin-left: 2px;
            }
            .star-icon:first-child {
              margin-left: 0px;
            }
          }
        }
        .progress {
          margin-left: 6px;
        }
        .rate {
          width: 28px;
          margin-left: 6px;
          font-weight: 500;
          font-size: 10px;
          color: #b3b3b3;
        }
      }
    }
  }
</style>
